/**
 * @file base_channel.cpp
 * @author 王烨
 * @date 2011-01-05
**/
#include <google/protobuf/descriptor.h>

#include "base_handler.h"

namespace skeleton
{
  using namespace std;
  using namespace google::protobuf;
  
  BaseHandler::BaseHandler(vector<google::protobuf::Service*> services)
  {
  }

  BaseHandler::BaseHandler(google::protobuf::Service *services[], int count)
  {
  }

  void BaseHandler::Listen(const std::string &addr, unsigned short port)
  {
    Listen(addr.c_str(), port);
  }

  void BaseHandler::CallMethod(const string &serviceName,
			       const string &methodName,
			       ServerController &controller)
  {
    hash_map<string, Service*>::iterator iter = services.find(serviceName);
    //没有找到被调用的service
    if (iter == services.end())
      throw RPCError(SERVICE_NOT_FOUND, string("Service not found:") + serviceName);
    Service *service = iter->second();
    const MethodDescriptor *method = service->GetDescriptor()->FindMethodByName(methodName);
